"""
数据定义的类

CREATE TABLE `orders`(
	`order_date` DATE NOT NULL,
	`order_id` VARCHAR(255) NOT NULL,
	`money` INT(10) NOT NULL,
	`province` VARCHAR(10) NOT NULL,
	PRIMARY KEY (`order_id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8
"""

import json

class Record:

    def __init__(self, date, order_id, money, province):
        self.date = date  # 订单日期
        self.order_id = order_id  # 订单ID
        self.money = money  # 订单金额
        self.province = province  # 销售省份

    def __str__(self):
        return f"{self.date}, {self.order_id}, {self.money}, {self.province}"

    def to_json(self):
        d = {"date": self.date.strftime('%Y-%m-%d'), "order_id": self.order_id, "money": self.money, "province": self.province}
        return json.dumps(d)
